<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item label="站点名称">
          <el-input
            v-model="dataForm.stationName"
            placeholder="请输入站点名称"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="位置">
          <el-input
            v-model="dataForm.address"
            placeholder="请输入位置"
            clearable
          ></el-input>
        </el-form-item>
        <!-- <el-form-item>
            <ren-select v-model="dataForm.gender" dict-type="gender" :placeholder="$t('user.gender')"></ren-select>
          </el-form-item>
          <el-form-item>
            <ren-dept-tree v-model="dataForm.deptId" :placeholder="$t('dept.title')" :query="true"></ren-dept-tree>
          </el-form-item> -->
        <el-form-item>
          <el-button @click="getDataList()">{{ $t("query") }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="addOrUpdateHandle()"
            >新增</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button
            type="danger"
            @click="deleteClick('','Batch')"
            >删除</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        height="805"
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
      >
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column type="index" header-align="center" align="center" label="序号" width="50"></el-table-column>
        <el-table-column
          prop="stationName"
          label="站点名称"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="stationCode"
          label="站点代码"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="address"
          label="位置"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="province"
          label="省份"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="city"
          label="城市"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="area"
          label="区域"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="contacts"
          label="联系人名称"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="contactsNumber"
          label="联系人电话"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="branchChns"
          label="适用车系"
          header-align="center"
          align="center"
        >
        <template slot-scope="scope">
          <div>
            <span v-if="scope.row.branchChns&&scope.row.branchChns.length>0">{{ scope.row.branchChns.join(',') }}</span> 
          </div>
        </template>
        </el-table-column>
        <el-table-column
          prop="stationOnlineStatus"
          label="站点线上状态"
          header-align="center"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="type"
          label="类别"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <div>
              {{
                scope.row.type == 0
                  ? "服务站"
                  : scope.row.type == 1
                  ? "经销商"
                  : scope.row.type == 3
                  ? "4S"
                  : scope.row.type == 4
                  ? "备件经销商"
                  : "-"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="addOrUpdateHandle(scope.row.id)"
              >修改</el-button
            >
            <el-button type="text" size="small" @click="deleteClick(scope.row.id,'single')">删除</el-button>
            <el-button type="text" size="small" @click="isShow(scope.row)"
              > {{ scope.row.status == 1 ?"禁用":"启用"  }} </el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @canCle="canCle"
        @refreshDataList="getDataList"
      ></add-or-update>
    </div>
  </el-card>
</template>
  
<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./dealer-add-update.vue";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/storemanage/page",
        getDataListIsPage: true,
        deleteURL: "/storemanage/delete",
        deleteIsBatch: false,
        exportURL: "",
      },
      dataForm: {
        stationName: "",
        address: "",
      },
    };
  },
  components: {
    AddOrUpdate,
  },
  methods: {
    isShow(val) {
      let that= this
      let word = val.status == 1 ? "禁用" : "启用";
      this.$confirm("是否确认在小程序中" + word + '该经销商', "提示", {
        iconClass: "el-icon-question", //自定义图标样式
        confirmButtonText: "确认", //确认按钮文字更换
        cancelButtonText: "取消", //取消按钮文字更换
        showClose: true, //是否显示右上角关闭按钮
        type: "warning", //提示类型  success/info/warning/error
      })
        .then(function () {
          //确认操作
          that.show(val.id,val.status);
        })
        .catch(function (err) {
          //捕获异常
        });
    },
    show(id, type) {
        let Status = type == 1?0:1
      this.$http
        .get("/storemanage/updateStatus", {
          params: {
            id,
            Status,
          },
        })
        .then((res) => {
          this.query()
        });
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-table__header, 
::v-deep .el-table__body{
  overflow: hidden;
  width: 99% !important;
}

</style>


  